package com.ocom.oauth.controller;

import com.ocom.common.utils.RequestUtil;
import com.ocom.oauth.po.AiotLoginPo;
import com.ocom.oauth.po.SmsCodePo;
import com.ocom.oauth.utils.UrlUtil;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
public class SmsCodeController {
    private final Logger log = LoggerFactory.getLogger(SmsCodeController.class);
    @PostMapping("/phoneLogin")
    public String login(@Validated @RequestBody SmsCodePo smsCodePo){
        Map<String,Object> requstMap =new HashMap<>();
        requstMap.put("grant_type",smsCodePo.getGrant_type());
        requstMap.put("client_id",smsCodePo.getClient_id());
        requstMap.put("client_secret",smsCodePo.getClient_secret());
        requstMap.put("phone",smsCodePo.getPhone());
        requstMap.put("code",smsCodePo.getCode());
        requstMap.put("comId",smsCodePo.getComId());
        log.info("requstMap{{}}",requstMap);
        return RequestUtil.doPostForm(UrlUtil.getUrl()+"/login", requstMap);
    }
}
